<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" href="../css/fonts/font-awesome.min.css">
        <link rel="stylesheet" href="../css/ui-box.css">
        <link rel="stylesheet" href="../css/ui-base.css">
        <link rel="stylesheet" href="../css/ui-color.css">
        <link rel="stylesheet" href="../css/appcan.icon.css">
        <link rel="stylesheet" href="../css/appcan.control.css">
        <link rel="stylesheet" href="../css/my/style.css">
    </head>
    <body class="um-vp" ontouchstart>
        <div id="page_0" class="my-body up ub ub-ver bc-bg" tabindex="0">
            <!--header开始-->
            <div id="header" class="my-header uh bc-text-head ub bc-head">
                <!-- 返回按钮开始 -->
                <div class="nav-btn" id="nav-left">
                    <div class="fa fa-angle-left ulev2"></div>
                </div>
                <!-- 返回按钮结束 -->
                <h1 class="ut ub-f1 ulev-3 ut-s tx-c" tabindex="0">后台JS</h1>
                <div class="nav-btn" id="nav-right"></div>
            </div>
            <div id="content" class="my-content-full1" style="background: #ebebeb;">
                <div class="ub-f1 ub-ver">
                    <div class="tx-c uinn">
                        <div id="btnStart" class="my-btn uc-a1 uinn bc-text-head uhide">
                            开启追踪
                        </div>
                    </div>
                    <div class="tx-c uinn">
                        <div id="btnStop" class="my-btn uc-a1 uinn bc-text-head uhide">
                            关闭追踪
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script src="../js/appcan.js"></script>
        <script src="../js/appcan.control.js"></script>
        <script src="../js/appcan.listview.js"></script>
        <script src="../js/my/smb.utils.js"></script>
        <script src="../js/my/smb.request.js"></script>
        <script src="../js/my/smb.window.js"></script>
        <script src="../js/my/smb.localStorage.js"></script>
        <script src="../js/my/smb.log.js"></script>
    </body>
    <script>
        var pageName = "JSBackground";
        var map = undefined;
        appcan.ready(function() {
            pageName = smb_GetLatestOpenedWindow() || pageName;
            //导航按钮返回事件
            appcan.button("#nav-left", "btn-act", function() {
                try {

                } catch(e) {
                    smb_WriteLog(pageName, e, true);
                }
                smb_CloseWindow(-1);
            });

            fnChangeToShowBtn();
            appcan.button("#btnStop", "btn-act", function() {
                smb_WriteLog(pageName, "关闭", true);
                uexLocation.closeLocation();
                uexBackground.stop();
                //uexWindow.putLocalData('JSBackground', '0');
                fnChangeToShowBtn();
            });
            appcan.button("#btnStart", "btn-act", function() {
                try {
                    smb_WriteLog(pageName, "启动", true);
                    var data = {
                        jsPath : "res://bg.js"
                    }
                    var result = uexBackground.start(data);
                    smb_WriteLog(pageName, "启动-" + result, true);
                    if (result)
                        fnChangeToShowBtn();
                    else {
                        alert("Start失败！");
                    }
                } catch(e) {
                    smb_WriteLog(pageName, "异常", true);
                }
            });
        });

        function fnChangeToShowBtn() {
            //var bJSBg = uexWindow.getLocalData("JSBackground") == "1";
            //if (bJSBg) {
            $("#btnStop").removeClass("uhide");
            //    $("#btnStart").addClass("uhide");
            //} else {
            //    $("#btnStop").addClass("uhide");
            $("#btnStart").removeClass("uhide");
            //}
        }
    </script>
</html>